package com.flk.oauth.vaildatecode;

import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author xxwy
 * on 2018/8/22 0022
 */
@Data
public class ValidateCode implements Serializable {
    private static final long serialVersionUID = 4005618089855660915L;
    private String code;
    private LocalDateTime expriteTime;

    public ValidateCode(String code, LocalDateTime expriteTime) {
        this.code = code;
        this.expriteTime = expriteTime;
    }

    public ValidateCode(String code, int expireIn) {
        this.code = code;
        this.expriteTime = LocalDateTime.now().plusSeconds(expireIn);
    }

    public ValidateCode() {
    }

    public boolean isExpired() {
        return LocalDateTime.now().isAfter(expriteTime);
    }
}
